import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class Demo2 {
    public static void main(String[] args) throws IOException {
        try(InputStream inputStream = new FileInputStream("./test2.txt")) {
            byte[] bytes = new byte[1024];
            int n = inputStream.read(bytes);
            for (int i = 0; i < n; i++) {
                System.out.printf("0x%x",bytes[i]);
            }
        }
        //将流对象的创建写到 try 的()中,此时代码执行完 try() 之后,就会自动调用 inputStream 的 close 了
    }
}
